<template>
    <div class="customer-form">
        <el-form :model="form" label-width="120px">
            <el-form-item label="公司名称" required>
                <el-input v-model="form.companyName" placeholder="请输入公司名称" />
            </el-form-item>

            <el-form-item label="联系人" required>
                <el-input v-model="form.contactPerson" placeholder="请输入联系人姓名" />
            </el-form-item>

            <el-form-item label="联系方式" required>
                <el-input v-model="form.contactInfo" placeholder="请输入电话或邮箱" />
            </el-form-item>

            <el-form-item label="报价日期" required>
                <el-date-picker v-model="form.quoteDate" type="date" placeholder="选择报价日期" value-format="YYYY-MM-DD" />
            </el-form-item>

            <el-form-item label="需求描述" required>
                <el-input v-model="form.requirementDescription" type="textarea" :rows="4" placeholder="请输入详细的需求描述" />
            </el-form-item>

            <el-form-item>
                <el-button @click="handlePrev">上一步</el-button>
                <el-button type="primary" @click="handleSubmit">下一步：生成报价单</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script setup>
import { ref, reactive } from 'vue'

const form = reactive({
    companyName: '',
    contactPerson: '',
    contactInfo: '',
    quoteDate: '',
    requirementDescription: ''
})

const emit = defineEmits(['prev', 'next'])

const handlePrev = () => {
    emit('prev')
}

const handleSubmit = () => {
    // 简单的表单验证
    if (!form.companyName || !form.contactPerson || !form.contactInfo ||
        !form.quoteDate || !form.requirementDescription) {
        ElMessage.warning('请填写所有必填字段')
        return
    }

    emit('next', { ...form })
}
</script>